package com.ajou.adonate.imap;

import java.util.HashMap;

public class MailContext {

	private String m_FileName = null;
	private String m_FileFormat = null;
	private String m_FileDescription = null;
	private int m_FileSize = 0;
	private int m_FileHashId = 0;
	private int m_FileCount = 0;
	private int m_DirectoryId = 0;
	private HashMap<String,Integer> m_MailNumLsit = new HashMap<String,Integer>(); 
		
	private int m_IndexNum  = 0;
	
	public MailContext(){
	}

	public int getFileCount() {
		return m_FileCount;
	}
	
	public void setFileDescription(String m_FileDescription) {
		this.m_FileDescription = m_FileDescription;
	}

	public String getFileDescription() {
		return m_FileDescription;
	}

	public void setDirectoryId(int m_DirectoryId) {
		this.m_DirectoryId = m_DirectoryId;
	}

	public int getDirectoryId() {
		return m_DirectoryId;
	}

	public void setFileFormat(String FileFormat) {
		this.m_FileFormat = FileFormat;
	}

	public String getFileFormat() {
		return m_FileFormat;
	}

	public void setFileSize(int FileSize) {
		this.m_FileSize = FileSize;
	}

	public int getFileSize() {
		return m_FileSize;
	}

	public void setFileName(String FileName) {
		int flag = FileName.indexOf(".");
		setFileFormat(FileName.substring(flag+1, FileName.length()));
		FileName = FileName.substring(0, flag);
		
		this.m_FileName = FileName;
	}

	public String getFileName() {
		return m_FileName;
	}

	void setIndexNum(int tempNum) {
		m_IndexNum = tempNum;
	}

	int getIndexNum() {
		return m_IndexNum;
	}
	
	int getMailCount() {
		return m_MailNumLsit.size();
		
	}
	
	public void setFileHashId(int FileHashId) {
		this.m_FileHashId = FileHashId;
	}
	
	public int getFileHashId() {
		return m_FileHashId;
	}
	
	public HashMap<String,Integer> getMailNumList() {
		return m_MailNumLsit;
	}
	
	public void AddMailContext(MailContext context, int mailnum) {
		if(context.getFileName().equals(this.getFileName())  && context.getFileHashId() == this.getFileHashId()) {
			AddMailNum(context.getIndexNum(), mailnum);
		}
	}
	
	public String toString() {
		return new String("[ADONATE]" +
				   "[File Name:"+m_FileName + "]" +
				   "[File Hash:" + Integer.valueOf(m_FileHashId).toString() + "]" +
				   "[Size:" + Integer.valueOf(m_FileSize).toString() +"]");
	}
	
	public Boolean AddMailNum(int Index, int mailnum) {
		Boolean reflag = false;
		String IndexNum = new Integer(Index).toString();
		if(m_MailNumLsit.containsKey(IndexNum) == false)
		{
			m_MailNumLsit.put(IndexNum, new Integer(mailnum));
			reflag = true;
			m_FileCount++;
		}
		return reflag;
		
	}
}
